<!DOCTYPE html>
<html>
<head>
<title>修改密码</title>
#include("/admin/_common/head.html")
<!-- 样 式 文 件 -->
<link rel="stylesheet" href="#CTX()/admin/css/form.css?_v=#VERSION()" />
</head>
<!-- 代 码 结 构 -->
<body class="pear-container">
<form class="layui-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">旧密码</label>
        <div class="layui-input-block">
            <input name="oldPassword" type="password" placeholder="请输入旧密码" lay-verify="required|oldPassword" autocomplete="off" class="layui-input" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">新密码</label>
        <div class="layui-input-block">
            <input name="newPassword" type="password" placeholder="请输入新密码" lay-verify="required|newPassword" autocomplete="off" class="layui-input" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">确认密码</label>
        <div class="layui-input-block">
            <input name="confirmPassword" type="password" placeholder="请输入确认密码" lay-verify="required|confirmPassword" autocomplete="off" class="layui-input" />
        </div>
    </div>
    <div class="bottom" style="display: none;">
        <div class="button-container">
            <button type="submit" class="layui-btn layui-btn-xs" lay-submit="" lay-filter="data-save" id="data-save">
                <i class="layui-icon layui-icon-ok"></i> 提交
            </button>
        </div>
    </div>
</form>
<!-- 资 源 引 入 -->
#include("/admin/_common/foot.html")
<script>
layui.use(['form', 'jquery'], function() {
    var $ = layui.jquery, form = layui.form;
    
    /*
     * 自定义验证规则
     */
    form.verify({
        oldPassword: (value, item) => {
            if (value.length < 6 || value.length > 20) {
                return '当前密码必须6到20位字符';
            }
        },
        newPassword: (value, item) => {
            if (value.length < 6 || value.length > 20) {
                return '新密码必须6到20位字符';
            }
        },
        confirmPassword: (value, item) => {
            if (value != $('[name="confirmPassword"]').val()) {
                return '确认密码必须和新密码相同';
            }
        }
    });
});
</script>
</body>
</html>
